package com.topwalk.datacollect.enumI;

import org.springframework.util.StringUtils;

public enum ServerEnum {
    VIDEO("video"),
    DBEXCHANGELOG("DBExchangeLog"),
    FILEEXCHANGELOG("FileExchangeLog");

    private String serverCode;

    private ServerEnum(String serverCode){
        this.serverCode = serverCode;
    }

    private String getServerCode() {
        return serverCode;
    }


    public static ServerEnum getTypeByServerCode(String serverCode){
        if(StringUtils.isEmpty(serverCode)){
            throw new IllegalArgumentException("参数不能为空");
        }

        for(ServerEnum serverEnum : ServerEnum.values()){
            if(serverEnum.getServerCode().equalsIgnoreCase(serverCode)){
                return serverEnum;
            }
        }

        throw new IllegalArgumentException("未找到server类型："+serverCode);
    }

}